/**
 * @class   wosh::interfaces::devices::PlayerAudio
 * @brief   Standard interface of generic audio player (device).
 *
 *
 * @see     wosh::devices::PlayerGStreamerBundle
 * @see     wosh::devices::PlayerPhononBundle
 * @see     wosh::devices::VlcPlayerBundle
 * @ingroup Interfaces
 ****************************************************************************
 * @version 0.8.384 $Id: PlayerAudio.h 2683 2010-06-21 09:17:31Z alex $
 * @author  Alessandro Polo
 ****************************************************************************/
/* Copyright (c) 2007-2010, WOSH - Wide Open Smart Home 
 * by Alessandro Polo - OpenSmartHome.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the OpenSmartHome.com WOSH nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Alessandro Polo ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Alessandro Polo BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ****************************************************************************/

#ifndef __WOSH_Interfaces_Devices_PlayerAudio_H__
 #define __WOSH_Interfaces_Devices_PlayerAudio_H__

 #include <interfaces/Device.h>


namespace wosh {
 namespace interfaces {
  namespace devices {

 #define _PlayerAudio_TYPE					"wosh::devices::PlayerAudio"

 #define _Player_METHOD_play				"play"
 #define _Player_METHOD_play_index			"play#"
 #define _Player_METHOD_enqueue				"enqueue"

 #define _Player_METHOD_remove				"remove"

 #define _Player_METHOD_synch				"synch"
 #define _Player_METHOD_get_medialist		"get_medialist"

 
 #define _Player_METHOD_pause				"pause"
 #define _Player_METHOD_stop				"stop"
 #define _Player_METHOD_next				"next"
 #define _Player_METHOD_prev				"prev"
 #define _Player_METHOD_first				"first"
 #define _Player_METHOD_last				"last"
 #define _Player_METHOD_clear				"clear"

 #define _Player_METHOD_set_volume			"volume"
 #define _Player_METHOD_set_mute			"mute"

 #define _Player_METHOD_set_position		"position"

 #define _Player_STATE_Idle					0x0000
 #define _Player_STATE_Playing				0x0001
 #define _Player_STATE_Paused				0x0002
 #define _Player_STATE_Unknown				0x0010

 #define _Player_VOLUME_Unknown				-1

 #define _Player_KEY_Mute					"Mute"
 #define _Player_KEY_Volume					"Volume"
 #define _Player_KEY_DeviceOutput			"DeviceOutput"
 #define _Player_KEY_CurrentFile			"CurrentFile"
 #define _Player_KEY_State					"PlayerState"
 #define _Player_KEY_CurrentLength			"Length"
 #define _Player_KEY_CurrentPosition		"Position"

 #define _Player_KEY_RepeatPlayList			"RepeatPlayList"
 #define _Player_KEY_RepeatItem				"RepeatItem"

 #define _Player_EVENT_PlayStateChanged		"PlayStateChanged"
 #define _Player_EVENT_VolumeChanged		"VolumeChanged"
 #define _Player_EVENT_MediaTrackChanged	"MediaTrackChanged"
 #define _Player_EVENT_MediaListChanged		"MediaListChanged"



class PlayerAudio : public virtual Device
 {
	WOSH_BUNDLE_INTERFACE("wosh::interfaces::devices::PlayerAudio")


/** @name PlayerAudio Interface - Playback
 * @{
 ******************************************************************************/
	public:

		//the file has to be in one of the following formats /perhaps a little bit outdated)
		/*
		[file://]filename              Plain media file
		http://ip:port/file            HTTP URL
		ftp://ip:port/file             FTP URL
		mms://ip:port/file             MMS URL
		screen://                      Screen capture
		[dvd://][device][@raw_device]  DVD device
		[vcd://][device]               VCD device
		[cdda://][device]              Audio CD device
		udp:[[<source address>]@[<bind address>][:<bind port>]]
		*/

		/**
		 * @brief   Play a resource
		 * @param file_url [in] the URI of the resource to be played. Multiple protocols are supported:
		 *                         - filesystem [file:///path/to/somefile.avi] (default: '/path/to/somefile.avi' will work too) 
		 *                           Also folders are supported, but it will clear the playlist and enqueue files, not recursive.
		 *                         - Network stream, HTTP [http://www.alessandropolo.name/music/sounday/Longe-at-the-Counter.mp3]
		 *                         - Compact Disc Digital Audio [cdda://4]
		 *                         - DVD [dvd://1]
		 */
		virtual WRESULT play( const std::string& file_url ) = 0;

		virtual WRESULT play( unsigned int index ) = 0;

		/**
		 * @brief   Play the current media.
		 * @return  
		 */
		virtual WRESULT play() = 0;

		/**
		 * @brief   Pause the current media, keeping track of position. Continue calling play()
		 * @return  
		 * @see     play()
		 */
		virtual WRESULT pause() = 0;

		/**
		 * @brief   Stop the current media.
		 * @return  
		 */
		virtual WRESULT stop() = 0;

		/**
		 * @brief   Play the first element in the playlist.
		 * @return  WRET_ERR_ILLEGAL_USE when playlist is empty/invalid; WRET_OK when playback is starting
		 */
		virtual WRESULT first() = 0;

		/**
		 * @brief   Play the next element in the playlist.
		 * @return  WRET_ERR_ILLEGAL_USE when playlist is empty/invalid; WRET_ERR_PARAM when out of index;
		 *          WRET_OK when playback is starting
		 */
		virtual WRESULT next() = 0;

		/**
		 * @brief   Play the previous element in the playlist.
		 * @return  WRET_ERR_ILLEGAL_USE when playlist is empty/invalid; WRET_ERR_PARAM when out of index;
		 *          WRET_OK when playback is starting
		 */
		virtual WRESULT prev() = 0;

		/**
		 * @brief   Play the last element in the playlist.
		 * @return  WRET_ERR_ILLEGAL_USE when playlist is empty/invalid; WRET_OK when playback is starting
		 */
		virtual WRESULT last() = 0;

//@}
/** @name PlayerAudio Interface - PlayList
 * @{
 ******************************************************************************/
	public:

		virtual WRESULT enqueue( const std::string& file_url ) = 0;

		/**
		 * @brief   Clear the playlist. Won't necessary stop current playback.
		 * @return  WRET_OK if playlist has been cleared. Check custom implementation error codes.
		 */
		virtual WRESULT clear() = 0;


//@}
/** @name PlayerAudio Interface - Setters
 * @{
 ******************************************************************************/
	public:

		/**
		 * @brief   Set the volume of device.
		 * @param [in] newVolume the volume level expressed in range [0; 100] 
		 * @return  
		 */
		virtual WRESULT setVolume(int newVolume) = 0;

		virtual WRESULT setVolumeOffset( int volume_span ) = 0;
		virtual WRESULT setMute( bool on ) = 0;

		virtual WRESULT setPosition( float position_rate ) = 0;
		virtual WRESULT setPositionOffset( float position_rate_offset ) = 0;

//@}
/** @name PlayerAudio Interface - Getters
 * @{
 ******************************************************************************/
	public:

		virtual int getVolume() = 0;
		virtual bool isMuted() = 0;

		virtual bool isPlaying() = 0;

		virtual int getPlaylistCount() = 0;

//@}


	public:
		virtual ~PlayerAudio() { }

}; // class def

  }; // namespace devices
 }; // namespace interfaces
}; // namespace wosh

#endif //__WOSH_Interfaces_Devices_PlayerAudio_H__
